import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver=webdriver.Edge()
driver.get('http://jiuxian.com')

# 点击请登录
driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]').click()
time.sleep(1)
# 输入账号密码
driver.find_element(By.ID,'userName').send_keys('18238680385')
driver.find_element(By.NAME,'_pwd').send_keys('123456Aa')
# 强等手动输入验证码
time.sleep(20)
# 点击登录
driver.find_element(By.XPATH,'//*[@id="save"]').click()
driver.find_element(By.ID,'bindSub').click()
time.sleep(3)
denglu=driver.find_element(By.CLASS_NAME,'greeting').text
print(denglu)
# 滚动
driver.execute_script("window.scrollTo(0,2000)")
time.sleep(2)
driver.execute_script('window.scrollTo(0,document.body.scrollHeight)')
time.sleep(2)
driver.execute_script('window.scrollTo(0,0)')
time.sleep(2)

driver.find_element(By.XPATH,'/html/body/div[4]/div/div[2]/div[2]/p/a[6]').click()
driver.switch_to.window(driver.window_handles[-1])
guotai=driver.find_element(By.XPATH,'/html/body/div[6]/div/div[2]/div[2]/div[2]/p[2]').text
print(guotai)
# 进入店铺
driver.find_element(By.CLASS_NAME,'btn').click()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(5)
#加入购物车
driver.execute_script('window.scrollTo(0,3000)')
driver.find_element(By.TAG_NAME,'_blank').click()


# driver.find_element(By.ID,'wd').send_keys('茅台')
# driver.find_element(By.CLASS_NAME,'search-btn').click()
# driver.find_element(By.CLASS_NAME,'img clearfix').click()
# driver.switch_to.window(driver.window_handles[-1])
# driver.find_element(By.ID,'addToCartForDetail').click()




# # 点击qq
# driver.find_element(By.CSS_SELECTOR,'#loginform > div > div > div > div > div.loginCon > div.cooperate > div > a.qq > i').click()
# time.sleep(1)
# # 进入frame页面
# f=driver.find_element(By.ID,'ptlogin_iframe')
# driver.switch_to.frame(f)
# # 退出frame页面
# driver.switch_to.default_content()
# time.sleep(1)
# # 点击qq头像
# driver.find_element(By.ID,'img_out_1847537889').click()

time.sleep(5)